package com.pda.xinma.ui.handingin;

import android.text.TextUtils;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.pda.xinma.R;
import com.pda.xinma.adapter.HandingInDetailAdapter;
import com.pda.xinma.bean.HnadingInDetailListBean;
import com.pda.xinma.contract.HandingInDetailContract;
import com.pda.xinma.presenter.HandingInDetailPresenter;
import com.wangshen.base.ui.mvp.base.ui.BaseMvpFragment;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.ArrayList;

import butterknife.BindView;

public class HandingInDetailFragment extends BaseMvpFragment<HandingInDetailPresenter> implements HandingInDetailContract.View {
    HandingInDetailAdapter adapter;
    @BindView(R.id.tv_deliveryNo)
    TextView tvDeliveryNo;
    @BindView(R.id.rv_content)
    RecyclerView rvContent;
    public HandingInDetailFragment(String entryNo) {
        this.entryNo = entryNo;
    }

    public HandingInDetailFragment() {
    }

    private String entryNo;
    @Override
    public HandingInDetailPresenter getPresenter() {
        return new HandingInDetailPresenter();
    }

    @Override
    public int getViewId() {
        return R.layout.fragment_detail;
    }

    @Override
    public void initView() {
        EventBus.getDefault().register(this);
        tvDeliveryNo.setText("入库单信息 " + entryNo);
        adapter = new HandingInDetailAdapter(R.layout.item_hand_in_detail, new ArrayList<>());
        rvContent.setAdapter(adapter);
        if (!TextUtils.isEmpty(entryNo)){
            presenter.entryDetail(entryNo);
        }
        //presenter.entryDetail(entryNo);
    }
    @Subscribe
    public void onEvent(String entry){
        entryNo=entry;
        tvDeliveryNo.setText("入库单信息 " + entryNo);
        presenter.entryDetail(entryNo);
    }
    @Override
    public void initLinsenterner() {

    }

    @Override
    public void getData() {

    }

    @Override
    public void setData(HnadingInDetailListBean bean) {
        adapter.setNewInstance(bean.getInfoVoList());
    }
}
